const { checkTokenUser } = require("../middleware/jwt");
const userAddressController = require("../controllers/address");

module.exports = async (app) => {
  // 为所有 /user/address 开头的路由注册中间件
  app.use("/user/address", checkTokenUser);
  app.use("/user/addressAll", checkTokenUser);

  // 地址相关路由
  app.post("/user/address", userAddressController.createAddress);
  app.delete("/user/address/:id", userAddressController.deleteAddress);
  app.put("/user/address/:id", userAddressController.updateAddress);
  app.get("/user/address/:id", userAddressController.getAddressById);
  app.get("/user/addressAll", userAddressController.getAllAddresses);
};